import { createRequest } from '/@/api/service';
const module = 'ib/visitor/v1/VisitorAppointmentApi';

/**
 * @function 提交访客邀请
 * @param data
 * @param header
 * @returns {Promise}
 */
function INSERT(
  data: VisitorAppointmentApi.InsertReq,
  header: object = {},
): Promise<VisitorAppointmentApi.InsertResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/insert`, data, header, 'POST');
}

/**
 * @function 提交访客邀请-没有联系方式
 * @param data
 * @param header
 * @returns {Promise}
 */
function INSERT_NO_PHONE(
  data: VisitorAppointmentApi.InsertNoPhoneReq,
  header: object = {},
): Promise<VisitorAppointmentApi.InsertNoPhoneResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/insertNoPhone`, data, header, 'POST');
}

/**
 * @function 取消访客邀请
 * @param data
 * @param header
 * @returns {Promise}
 */
function CANCEL(
  data: VisitorAppointmentApi.CancelReq,
  header: object = {},
): Promise<VisitorAppointmentApi.CancelResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/cancel`, data, header, 'POST');
}

/**
 * @function 同意访客邀请
 * @param data
 * @param header
 * @returns {Promise}
 */
function ACCEPT(
  data: VisitorAppointmentApi.AcceptReq,
  header: object = {},
): Promise<VisitorAppointmentApi.AcceptResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/accept`, data, header, 'POST');
}

/**
 * @function 拒绝访客邀请
 * @param data
 * @param header
 * @returns {Promise}
 */
function REJECT(
  data: VisitorAppointmentApi.RejectReq,
  header: object = {},
): Promise<VisitorAppointmentApi.RejectResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/reject`, data, header, 'POST');
}

/**
 * @function 访客签离
 * @param data
 * @param header
 * @returns {Promise}
 */
function OUT(
  data: VisitorAppointmentApi.OutReq,
  header: object = {},
): Promise<VisitorAppointmentApi.OutResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/out`, data, header, 'POST');
}

/**
 * @function 查询访客邀请记列表-返回数据为登录者提交的
 * @param data
 * @param header
 * @returns {Promise}
 */
function MY_LIST(
  data: VisitorAppointmentApi.MyListReq,
  header: object = {},
): Promise<VisitorAppointmentApi.MyListResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/myList`, data, header, 'POST');
}

/**
 * @function 查看访客邀请详情-返回数据为登录者提交的
 * @param data
 * @param header
 * @returns {Promise}
 */
function MY_DETAIL(
  data: VisitorAppointmentApi.MyDetailReq,
  header: object = {},
): Promise<VisitorAppointmentApi.MyDetailResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/myDetail`, data, header, 'POST');
}

/**
 * @function 会客地点列表
 * @param data
 * @param header
 * @returns {Promise}
 */
function MEETING_LOCATION_LIST(
  data: {},
  header: object = {},
): Promise<VisitorAppointmentApi.MeetingLocationListResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/meetingLocationList`,
    data,
    header,
    'POST',
  );
}

export {
  INSERT,
  INSERT_NO_PHONE,
  CANCEL,
  ACCEPT,
  REJECT,
  OUT,
  MY_LIST,
  MY_DETAIL,
  MEETING_LOCATION_LIST,
};
